package com.test.utils;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class CommonPage {
    public WebElement findElementBy(WebDriver driver, String method, String Element){
        if ("id".equals(method)){
          return   driver.findElement(By.id(Element));
        }
        if ("class_name".equals(method)){
            return driver.findElement(By.className(Element));
        }
        if ("tagName".equals(method)){
            return  driver.findElement(By.tagName(Element));
        }
        if ("xpath".equals(method)){
            return  driver.findElement(By.xpath(Element));
        }
        if ("cssSelector".equals(method)){
            return  driver.findElement(By.cssSelector(Element));
        }
        if ("linkText".equals(method)){
            return  driver.findElement(By.linkText(Element));
        }
        if ("name".equals(method)){
            return  driver.findElement(By.name(Element));
        }
        return null;
    }
}
